<%@ page import="cn.edu.hbcit.text1.StudentDb" %>
<%@ page import="java.sql.ResultSet" %>
<%@ page import="java.util.List" %>
<%@ page import="cn.edu.hbcit.text1.Student" %><%--
  Created by IntelliJ IDEA.
  User: 11507
  Date: 2019/6/20
  Time: 10:59
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>欢迎使用本系统</title>
</head>
<body>
<div class="container">

    <%@include file="template/header.jsp" %>

    <h2>信息如下</h2>
    <p>您可以实现增删改查几个功能</p>
    <form class="form-inline" action="student_search.jsp">
        <input name="sname" class="form-control col-2" type="text" placeholder="Search" id="search">
        <button class="btn btn-success col-1" type="submit">Search</button>
        <button type="button" class="btn btn-outline-primary offset-6 col-1" onclick="addForm()">增加数据</button>
        <button type="button" class="btn btn-outline-danger col-1" onclick="delForm()">删除数据</button>
        <button type="button" class="btn btn-outline-warning col-1" onclick="alterForm()">修改数据</button>
    </form>
    <table class="table table-striped">
        <thead>
        <tr>
            <th>学号</th>
            <th>姓名</th>
            <th>年龄</th>
            <th>性别</th>
            <th>班级</th>
            <th>民族</th>
            <th>籍贯</th>
            <th>专业</th>
        </tr>
        </thead>
        <tbody>
            <%
        ServletContext context =(ServletContext)request.getServletContext();
        String acountNumber = (String) context.getAttribute("acountNumber");
        List<Student> list = StudentDb.selUserData(acountNumber);
        for (Student stu:list) {
        out.print("<tr>");
        out.print("<td>");
        out.print(stu.getStuId());
        out.print("</td>");
        out.print("<td>");
        out.print(stu.getStuMame());
        out.print("</td>");
        out.print("<td>");
        out.print(stu.getStuAge());
        out.print("</td>");
        out.print("<td>");
        out.print(stu.getStuSex());
        out.print("</td>");
        out.print("<td>");
        out.print(stu.getStuClass());
        out.print("</td>");
        out.print("<td>");
        out.print(stu.getStuNation());
        out.print("</td>");
        out.print("<td>");
        out.print(stu.getStuNativePlace());
        out.print("</td>");
        out.print("<td>");
        out.print(stu.getStuMajor());
        out.print("</td>");
        out.print("<td>");
        out.print("</tr>");
      }
    %>
        <form action="addStu.jsp" role="form">
            <div class="form-group row" id="addStuForm">
                <input name="add_id" placeholder="学号" class="form-control col-2"/>
                <input name="name" placeholder="姓名" class="form-control col-1"/>
                <input name="age" placeholder="年龄" class="form-control col-1"/>
                <input name="sex" placeholder="性别" class="form-control col-1"/>
                <input name="class" placeholder="班级" class="form-control col-1"/>
                <input name="place" placeholder="籍贯" class="form-control col-1"/>
                <input name="major" placeholder="专业" class="form-control col-1"/>
                <input name="nation" placeholder="民族" class="form-control col-1"/>
                <button type="submit" class="btn btn-primary btn btn-default offset-2 col-1">增加</button>
            </div>
        </form>

        <form action="delStu.jsp" role="form">
            <div class="form-group row" id="delStuForm">
                <input name="id_2" placeholder="学号" class="form-control col-2"/>
                <input name="name_2" placeholder="姓名" class="form-control col-1"/>
                <button type="submit" class="btn btn-primary btn btn-danger col-1 offset-8">删除</button>
            </div>
        </form>

        <form action="student_alter.jsp" role="form">
            <div class="form-group row" id="alterStuForm">
                <input name="name_3" placeholder="姓名" class="form-control col-3"/>
                <button type="submit" class="btn btn-primary btn btn-warning col-1 offset-8">修改</button>
            </div>
        </form>

        <%@include file="template/footer.jsp" %>
</div>
<%@include file="template/link.jsp" %>


<script>
    // $("#addStuForm").hide();
    // $("#delStuForm").hide();
    // $("#alterStuForm").hide();
    $("#addStuForm").hide();
    $("#delStuForm").hide();
    $("#alterStuForm").hide();

    function addForm() {
        $("#addStuForm").show();
    }

    function delForm() {
        $("#delStuForm").show();
    }

    function alterForm() {
        $("#alterStuForm").show();
    }


    // function getSearchValue(){
    //     var inputValue = document.getElementById('search').value;
    //     alert(inputValue);
    //     document.getElementById('search').name = inputValue;
    // }
</script>
</body>
</html>
